<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"mixley.github.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="全栈·架构设计·算法">
<meta property="og:type" content="website">
<meta property="og:title" content="mixley">
<meta property="og:url" content="https://mixley.github.io/page/2/index.html">
<meta property="og:site_name" content="mixley">
<meta property="og:description" content="全栈·架构设计·算法">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="mixley">
<meta property="article:tag" content="mixley,前端,后端,全栈,收集,java,人脸识别,架构设计,spring,aop,spring boot,spring cloud,深度学习,vue,杂七杂八">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://mixley.github.io/page/2/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>mixley</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?c36eb18366b436984557126f16796f30";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">mixley</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">求上者得中·求中者得下</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/145360.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/145360.html" class="post-title-link" itemprop="url">nacos</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-05-13 13:33:18" itemprop="dateModified" datetime="2022-05-13T13:33:18+08:00">2022-05-13</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/operations/" itemprop="url" rel="index"><span itemprop="name">运维</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/operations/docker/" itemprop="url" rel="index"><span itemprop="name">docker</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/145360.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/145360.html" class="cy_cmt_count" data-xid="2022/145360.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">docker pull nacos/nacos-server</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/niunafei/p/12803965.html">https://www.cnblogs.com/niunafei/p/12803965.html</a></p>
<p>url后缀需要添加：&amp;serverTimezone=UTC</p>
<p>完整：</p>
<figure class="highlight properties"><table><tr><td class="code"><pre><span class="line"><span class="attr">MYSQL_SERVICE_DB_PARAM</span>=<span class="string">characterEncoding=utf8&amp;connectTimeout=1000&amp;socketTimeout=3000&amp;autoReconnect=true&amp;useSSL=false&amp;serverTimezone=UTC</span></span><br><span class="line"><span class="attr">SPRING_DATASOURCE_PLATFORM</span>=<span class="string">mysql</span></span><br><span class="line"><span class="attr">MYSQL_DATABASE_NUM</span>=<span class="string">1</span></span><br><span class="line"><span class="attr">MYSQL_SERVICE_HOST</span>=<span class="string">128.0.0.172</span></span><br><span class="line"><span class="attr">MYSQL_SERVICE_PORT</span>=<span class="string">3307</span></span><br><span class="line"><span class="attr">MYSQL_SERVICE_DB_NAME</span>=<span class="string">nacos</span></span><br><span class="line"><span class="attr">MYSQL_SERVICE_USER</span>=<span class="string">root</span></span><br><span class="line"><span class="attr">MYSQL_SERVICE_PASSWORD</span>=<span class="string">1234</span></span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">docker run -d \</span><br><span class="line">-e PREFER_HOST_MODE=hostname \</span><br><span class="line">-e MODE=standalone \</span><br><span class="line">-e SPRING_DATASOURCE_PLATFORM=mysql \</span><br><span class="line">-e MYSQL_MASTER_SERVICE_HOST=127.0.0.1 \</span><br><span class="line">-e MYSQL_MASTER_SERVICE_PORT=3306 \</span><br><span class="line">-e MYSQL_MASTER_SERVICE_USER=nacos_config \</span><br><span class="line">-e MYSQL_MASTER_SERVICE_PASSWORD=DdsNLrPeRfZiDGNE \</span><br><span class="line">-e MYSQL_MASTER_SERVICE_DB_NAME=nacos_config \</span><br><span class="line">-e MYSQL_SLAVE_SERVICE_HOST=127.0.0.1 \</span><br><span class="line">-p 8848:8848 \</span><br><span class="line">--name nacos \</span><br><span class="line">--restart=always \</span><br><span class="line">nacos/nacos-server</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">开启鉴权，切换端口</span></span><br><span class="line">docker run -d \</span><br><span class="line">-e PREFER_HOST_MODE=hostname \</span><br><span class="line">-e MODE=standalone \</span><br><span class="line">-e SPRING_DATASOURCE_PLATFORM=mysql \</span><br><span class="line">-e MYSQL_DATABASE_NUM=1 \</span><br><span class="line">-e MYSQL_SERVICE_HOST=10.177.43.37 \</span><br><span class="line">-e MYSQL_SERVICE_PORT=3306 \</span><br><span class="line">-e MYSQL_SERVICE_USER=root \</span><br><span class="line">-e MYSQL_SERVICE_PASSWORD=1234 \</span><br><span class="line">-e MYSQL_SERVICE_DB_NAME=nacos \</span><br><span class="line">-e NACOS_AUTH_CACHE_ENABLE=true \</span><br><span class="line">-e NACOS_AUTH_ENABLE=true \</span><br><span class="line">-e NACOS_APPLICATION_PORT=18848 \</span><br><span class="line">-p 18848:18848 \</span><br><span class="line">--name nacosAuth \</span><br><span class="line">--restart=always \</span><br><span class="line">nacos/nacos-server</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>


      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/3S92S0N.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/3S92S0N.html" class="post-title-link" itemprop="url">portainer</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-03-21 14:29:51" itemprop="dateModified" datetime="2022-03-21T14:29:51+08:00">2022-03-21</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/operations/" itemprop="url" rel="index"><span itemprop="name">运维</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/operations/docker/" itemprop="url" rel="index"><span itemprop="name">docker</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/3S92S0N.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/3S92S0N.html" class="cy_cmt_count" data-xid="2022/3S92S0N.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p><a target="_blank" rel="noopener" href="https://www.portainer.io/">https://www.portainer.io/</a></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/2W88D9Q.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/2W88D9Q.html" class="post-title-link" itemprop="url">批量插入</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-10-20 14:21:51" itemprop="dateModified" datetime="2021-10-20T14:21:51+08:00">2021-10-20</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/%E6%95%B0%E6%8D%AE%E5%BA%93/" itemprop="url" rel="index"><span itemprop="name">数据库</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/2W88D9Q.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/2W88D9Q.html" class="cy_cmt_count" data-xid="2022/2W88D9Q.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>批量方式插入数据库</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line">SqlSession batchSqlSession = <span class="keyword">null</span>;</span><br><span class="line"><span class="keyword">try</span> &#123;</span><br><span class="line">    <span class="comment">// 获取批量方式的sqlsession</span></span><br><span class="line">    batchSqlSession = sessionFactory.openSession(ExecutorType.BATCH, <span class="keyword">false</span>);</span><br><span class="line">    <span class="keyword">for</span> (Ticket ticket : tickets) &#123;</span><br><span class="line">        batchSqlSession.insert(<span class="string">&quot;com.newland.mapper.TicketMapper.insert&quot;</span>,ticket);</span><br><span class="line">    &#125;</span><br><span class="line">    batchSqlSession.commit();</span><br><span class="line">&#125;<span class="keyword">catch</span> (Exception e)&#123;</span><br><span class="line">    batchSqlSession.rollback();</span><br><span class="line">    e.printStackTrace();</span><br><span class="line">    <span class="keyword">throw</span> e;</span><br><span class="line">&#125;<span class="keyword">finally</span> &#123;</span><br><span class="line">    batchSqlSession.close();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/29G4ED9.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/29G4ED9.html" class="post-title-link" itemprop="url">nrm</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-11-09 21:43:46" itemprop="dateModified" datetime="2021-11-09T21:43:46+08:00">2021-11-09</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/node/" itemprop="url" rel="index"><span itemprop="name">node</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/29G4ED9.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/29G4ED9.html" class="cy_cmt_count" data-xid="2022/29G4ED9.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>npm install -g nrm</p>
<p>nrm ls   //查看镜像源, *表示正在使用的</p>
<pre><code>* npm -------- https://registry.npmjs.org/       
  yarn ------- https://registry.yarnpkg.com/     
  cnpm ------- http://r.cnpmjs.org/
  taobao ----- https://registry.npm.taobao.org/  
  nj --------- https://registry.nodejitsu.com/   
  npmMirror -- https://skimdb.npmjs.com/registry/
  edunpm ----- http://registry.enpmjs.org/       
</code></pre>
<p>nrm use taobao //切换</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/JGXQTS.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/JGXQTS.html" class="post-title-link" itemprop="url">npmrc与scope</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-04-29 11:04:34" itemprop="dateModified" datetime="2022-04-29T11:04:34+08:00">2022-04-29</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/node/" itemprop="url" rel="index"><span itemprop="name">node</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/JGXQTS.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/JGXQTS.html" class="cy_cmt_count" data-xid="2022/JGXQTS.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="npmrc简介"><a href="#npmrc简介" class="headerlink" title="npmrc简介"></a>npmrc简介</h2><p>我们经常会设置镜像源，用于加速，实际设置镜像源最终是保存在npm的配置文件中的，对应的配置文件叫.npmrc</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">npm config <span class="built_in">set</span> key value</span></span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash">下面是设置淘宝镜像的指令</span></span><br><span class="line">npm config set registry https://registry.npm.taobao.org</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash">下面是全局设置，带了-g</span></span><br><span class="line"><span class="meta">#</span><span class="bash">npm config <span class="built_in">set</span> registry https://registry.npm.taobao.org -g</span></span><br></pre></td></tr></table></figure>

<p>对应的.npmrc文件会出现用户目录或npm的安装目录(全局情况下)，并会有一个记录值</p>
<figure class="highlight ini"><table><tr><td class="code"><pre><span class="line"><span class="attr">registry</span>=https://registry.npm.taobao.org/</span><br></pre></td></tr></table></figure>

<p>优先级：<strong>项目配置&gt;用户配置&gt;全局配置</strong>，在项目根目录建立的.npmrc优先级别最高。仅支持单个地址。</p>
<h2 id="scope简介"><a href="#scope简介" class="headerlink" title="scope简介"></a>scope简介</h2><p>scope是作用域包的意思。使用@开头，到斜杠之间，整个包名带上域可以按”域”处理。</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">@scope/project-name</span><br></pre></td></tr></table></figure>

<p>域的作用更多是私服时使用，在发布时指定name=@scope/project-name，使用时，同样使用@scope/project-name。</p>
<p>在使用npm时可能会遇见私服A、私服B、私服C镜像的问题。但是按.npmrc文件的配置，我们也肯定知道，只能选择其中一个作为镜像地址。普遍的办法就是自己再搭建一个私服，引用A、B、C私服的包。还有一个更简单的办法是，指定域的服务地址。</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">设置@scope开头的包从test.npm下载</span></span><br><span class="line">npm config set @scope:registry https://test.npm.com</span><br><span class="line"><span class="meta">#</span><span class="bash">设置@testScope1开头的包从服务1.2.3.4下载</span></span><br><span class="line">npm config set @testScope1:registry http://1.2.3.4/npm-test/</span><br></pre></td></tr></table></figure>

<p>最后保留的.npmrc文件里面对应的是</p>
<figure class="highlight ini"><table><tr><td class="code"><pre><span class="line">@scope:<span class="attr">registry</span>=https://test.npm.com</span><br><span class="line">@testScope1:<span class="attr">registry</span>=http://<span class="number">1.2</span>.<span class="number">3.4</span>/npm-test/</span><br></pre></td></tr></table></figure>

<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>简单的处理方式：手动建立一个.npmrc直接丢<strong>项目</strong>里面啦<strong>（优先级最高）</strong>，记得文件要<strong>和package.json同级</strong>，根目录哦。打开项目就是npm install，私包和公共包全下载了。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/QWNFBS.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/QWNFBS.html" class="post-title-link" itemprop="url">install</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-22 17:07:09" itemprop="dateModified" datetime="2022-02-22T17:07:09+08:00">2022-02-22</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/node/" itemprop="url" rel="index"><span itemprop="name">node</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/QWNFBS.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/QWNFBS.html" class="cy_cmt_count" data-xid="2022/QWNFBS.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <figure class="highlight shell"><table><tr><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">指定windows-build-tools版本，4.0好安装一点</span></span><br><span class="line"><span class="meta">#</span><span class="bash">搞不定可以c</span></span><br><span class="line">npm install --global --production windows-build-tools@4.0.0</span><br></pre></td></tr></table></figure>


      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/C64GPN.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/C64GPN.html" class="post-title-link" itemprop="url">MQ</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-10-14 10:55:30" itemprop="dateModified" datetime="2021-10-14T10:55:30+08:00">2021-10-14</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/MQ/" itemprop="url" rel="index"><span itemprop="name">MQ</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/C64GPN.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/C64GPN.html" class="cy_cmt_count" data-xid="2022/C64GPN.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p><img src="/2022/C64GPN/1355489-20180823155405420-191105903.png" alt="img"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/S3R6PQ.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/S3R6PQ.html" class="post-title-link" itemprop="url">MAVEN使用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-06-10 13:55:20" itemprop="dateModified" datetime="2022-06-10T13:55:20+08:00">2022-06-10</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/java/maven/" itemprop="url" rel="index"><span itemprop="name">maven</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/S3R6PQ.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/S3R6PQ.html" class="cy_cmt_count" data-xid="2022/S3R6PQ.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="Maven生命周期及生命周期绑定"><a href="#Maven生命周期及生命周期绑定" class="headerlink" title="Maven生命周期及生命周期绑定"></a>Maven生命周期及生命周期绑定</h2><h3 id="生命周期"><a href="#生命周期" class="headerlink" title="生命周期"></a>生命周期</h3><p><strong>package</strong> <strong>即将本地编译好的文件打包为war 或者jar</strong> </p>
<p><strong>install</strong> <strong>将打包的代码存放到本地maven仓库，可供本地其它项目依赖使用</strong> </p>
<p><strong>deploy</strong> <strong>将打包在本地仓库中的项目发到服务器，供他人依赖使用</strong> </p>
<p><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image002.png" alt="img"></p>
<h3 id="Plugins绑定maven生命周期"><a href="#Plugins绑定maven生命周期" class="headerlink" title="Plugins绑定maven生命周期"></a>Plugins绑定maven生命周期</h3><p>新建一个plugin工具后，通过**<executions><phase><strong>绑定生命周期，maven-</strong>-plugin的groupId为org.apache.maven.plugins一般都有<strong>默认的生命周期</strong>。如maven-jar-plugin</phase></executions></p>
<p><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image004.jpg" alt="img"></p>
<h2 id="无法在maven中引用的lib包处理"><a href="#无法在maven中引用的lib包处理" class="headerlink" title="无法在maven中引用的lib包处理"></a>无法在maven中引用的lib包处理</h2><h3 id="Idea使用时报错处理"><a href="#Idea使用时报错处理" class="headerlink" title="Idea使用时报错处理"></a>Idea使用时报错处理</h3><p><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image006.jpg" alt="img"></p>
<h3 id="Maven编译打包报错时处理"><a href="#Maven编译打包报错时处理" class="headerlink" title="Maven编译打包报错时处理"></a>Maven编译打包报错时处理</h3><p><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image008.jpg" alt="img"></p>
<h2 id="Maven项目Version版本自动写入文件"><a href="#Maven项目Version版本自动写入文件" class="headerlink" title="Maven项目Version版本自动写入文件"></a>Maven项目Version版本自动写入文件</h2><h3 id="resources目录下-新增文件version"><a href="#resources目录下-新增文件version" class="headerlink" title="resources目录下 新增文件version"></a>resources目录下 新增文件version</h3><p>内容复制为：</p>
<figure class="highlight stylus"><table><tr><td class="code"><pre><span class="line">#$&#123;project.artifactId&#125;#$&#123;project.version&#125;#$&#123;project.packaging&#125;#$&#123;project.timestamp&#125;#</span><br></pre></td></tr></table></figure>

<p>截图示例：（下面的是目录结构及version中包含的内容）</p>
<p><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image010.jpg" alt="img"></p>
<h3 id="Properties配置"><a href="#Properties配置" class="headerlink" title="Properties配置"></a>Properties配置</h3><figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- 日期显示格式 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">maven.build.timestamp.format</span>&gt;</span>yyyy-MM-dd HH:mm:ss<span class="tag">&lt;/<span class="name">maven.build.timestamp.format</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- 对应version里面显示的project.timestamp --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">project.timestamp</span>&gt;</span>$&#123;maven.build.timestamp&#125;<span class="tag">&lt;/<span class="name">project.timestamp</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- 文件拷贝时的编码 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">project.build.sourceEncoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">project.build.sourceEncoding</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">project.reporting.outputEncoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">project.reporting.outputEncoding</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- 编译时的编码 --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">maven.compiler.encoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">maven.compiler.encoding</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- maven方式跳过maven test, 等同$ mvn package -Dmaven.test.skip=true --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">maven.test.skip</span>&gt;</span>true<span class="tag">&lt;/<span class="name">maven.test.skip</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="Build配置"><a href="#Build配置" class="headerlink" title="Build配置"></a>Build配置</h3><figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">finalName</span>&gt;</span>$&#123;artifactId&#125;<span class="tag">&lt;/<span class="name">finalName</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 编译配置，source源码版本target编译器版本1.7表示jdk7 --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-compiler-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.6.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">encoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">encoding</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">source</span>&gt;</span>1.7<span class="tag">&lt;/<span class="name">source</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">target</span>&gt;</span>1.7<span class="tag">&lt;/<span class="name">target</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 编译帮助工具，这里用作时区转换工具 --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.codehaus.mojo<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>build-helper-maven-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">            <span class="comment">&lt;!-- 执行这个命令timestamp-property --&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">goal</span>&gt;</span>timestamp-property<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">          <span class="comment">&lt;!-- 生命周期 validate时执行--&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">phase</span>&gt;</span>validate<span class="tag">&lt;/<span class="name">phase</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">            <span class="comment">&lt;!-- 替换project.timestamp的值(没有这里时区是UTC)--&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">name</span>&gt;</span>project.timestamp<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">pattern</span>&gt;</span>$&#123;maven.build.timestamp.format&#125;<span class="tag">&lt;/<span class="name">pattern</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">timeZone</span>&gt;</span>GMT+8<span class="tag">&lt;/<span class="name">timeZone</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 处理资源文件 --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-resources-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">          <span class="comment">&lt;!-- 生命周期 validate时执行--&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">phase</span>&gt;</span>validate<span class="tag">&lt;/<span class="name">phase</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">goal</span>&gt;</span>copy-resources<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">outputDirectory</span>&gt;</span>$&#123;project.build.directory&#125;/$&#123;project.build.finalName&#125;<span class="tag">&lt;/<span class="name">outputDirectory</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">resources</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">resource</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">directory</span>&gt;</span>src/main/resources<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">filtering</span>&gt;</span>true<span class="tag">&lt;/<span class="name">filtering</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">includes</span>&gt;</span></span><br><span class="line">                  <span class="comment">&lt;!-- 选择文件--&gt;</span></span><br><span class="line">                  <span class="tag">&lt;<span class="name">include</span>&gt;</span>version<span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">includes</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;/<span class="name">resource</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">resources</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h2 id="Maven常用工具"><a href="#Maven常用工具" class="headerlink" title="Maven常用工具"></a>Maven常用工具</h2><h3 id="jar包打包（需依赖外部lib）maven-jar-plugin"><a href="#jar包打包（需依赖外部lib）maven-jar-plugin" class="headerlink" title="jar包打包（需依赖外部lib）maven-jar-plugin"></a>jar包打包（需依赖外部lib）maven-jar-plugin</h3><figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-jar-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">archive</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">manifest</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">addClasspath</span>&gt;</span>true<span class="tag">&lt;/<span class="name">addClasspath</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">classpathPrefix</span>&gt;</span>lib/<span class="tag">&lt;/<span class="name">classpathPrefix</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">mainClass</span>&gt;</span>com.newland.buscontrol.message.MainServer<span class="tag">&lt;/<span class="name">mainClass</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">manifest</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">archive</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">outputDirectory</span>&gt;</span>../deploy/release<span class="tag">&lt;/<span class="name">outputDirectory</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="Jar单文件打包（无需依赖）maven-assembly-plugin"><a href="#Jar单文件打包（无需依赖）maven-assembly-plugin" class="headerlink" title="Jar单文件打包（无需依赖）maven-assembly-plugin"></a>Jar单文件打包（无需依赖）maven-assembly-plugin</h3><figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-assembly-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">phase</span>&gt;</span>package<span class="tag">&lt;/<span class="name">phase</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">goal</span>&gt;</span>assembly<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">archive</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">manifest</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">mainClass</span>&gt;</span>$&#123;mainClass&#125;<span class="tag">&lt;/<span class="name">mainClass</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">manifest</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">archive</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">appendAssemblyId</span>&gt;</span>false<span class="tag">&lt;/<span class="name">appendAssemblyId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">descriptorRefs</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">descriptorRef</span>&gt;</span>jar-with-dependencies<span class="tag">&lt;/<span class="name">descriptorRef</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">descriptorRefs</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">outputDirectory</span>&gt;</span>../deploy/release<span class="tag">&lt;/<span class="name">outputDirectory</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="配置清理及不清理的文件maven-clean-plugin"><a href="#配置清理及不清理的文件maven-clean-plugin" class="headerlink" title="配置清理及不清理的文件maven-clean-plugin"></a>配置清理及不清理的文件maven-clean-plugin</h3><p>**(<strong>与绑定生命周期一起用时，可以在package时清理一些指定文件)</strong></p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-clean-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">filesets</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">fileset</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">directory</span>&gt;</span>deploy/release<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">excludes</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">exclude</span>&gt;</span>BusControl.properties<span class="tag">&lt;/<span class="name">exclude</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">exclude</span>&gt;</span>排除文件.jar<span class="tag">&lt;/<span class="name">exclude</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">excludes</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">fileset</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">filesets</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h2 id="多模块项目（重复工作放在一个模块下）"><a href="#多模块项目（重复工作放在一个模块下）" class="headerlink" title="多模块项目（重复工作放在一个模块下）"></a>多模块项目（重复工作放在一个模块下）</h2><h3 id="多模块展示及创建方法（主模块右击新建模块）"><a href="#多模块展示及创建方法（主模块右击新建模块）" class="headerlink" title="多模块展示及创建方法（主模块右击新建模块）"></a>多模块展示及创建方法<strong>（主模块右击新建模块）</strong></h3><p><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image012.jpg" alt="img"><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image014.jpg" alt="img"></p>
<h3 id="指定项目中公有的模块"><a href="#指定项目中公有的模块" class="headerlink" title="指定项目中公有的模块"></a>指定项目中公有的模块</h3><p><strong>父pom指定公用模块</strong></p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="comment">&lt;!--指定项目中公有的模块--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependencyManagement</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.newland<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>Utils<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">version</span>&gt;</span>$&#123;project.version&#125;<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependencyManagement</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>子模块使用(可以不用指定版本号)</strong></p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.newland<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>Utils<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="指定项目公共插件及插件公共配置"><a href="#指定项目公共插件及插件公共配置" class="headerlink" title="指定项目公共插件及插件公共配置"></a>指定项目公共插件及插件公共配置</h3><p><strong>父pom指定公共插件</strong></p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-assembly-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">phase</span>&gt;</span>package<span class="tag">&lt;/<span class="name">phase</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">goal</span>&gt;</span>assembly<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">appendAssemblyId</span>&gt;</span>false<span class="tag">&lt;/<span class="name">appendAssemblyId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">descriptorRefs</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">descriptorRef</span>&gt;</span>jar-with-dependencies<span class="tag">&lt;/<span class="name">descriptorRef</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">descriptorRefs</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">outputDirectory</span>&gt;</span>../deploy/release<span class="tag">&lt;/<span class="name">outputDirectory</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>子模块使用（不需版本号与其它公共配置）</strong></p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-assembly-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">archive</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">manifest</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">mainClass</span>&gt;</span>$&#123;mainClass&#125;<span class="tag">&lt;/<span class="name">mainClass</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">manifest</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">archive</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h2 id="Maven模块引用配置"><a href="#Maven模块引用配置" class="headerlink" title="Maven模块引用配置"></a><strong>Maven</strong>模块引用配置</h2><h3 id="环境选择classifier（json-lib）"><a href="#环境选择classifier（json-lib）" class="headerlink" title="环境选择classifier（json-lib）"></a>环境选择classifier（json-lib）</h3><figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>net.sf.json-lib<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>json-lib<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.4<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">classifier</span>&gt;</span>jdk15<span class="tag">&lt;/<span class="name">classifier</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="Jar包冲突之运行环境冲突-使用provided"><a href="#Jar包冲突之运行环境冲突-使用provided" class="headerlink" title="Jar包冲突之运行环境冲突**(**使用provided)"></a><strong>Jar</strong>包冲突之运行环境冲突**(**使用<scope>provided</scope>)</h3><p>在运行环境中存在（tomcat中）且项目中需要直接使用的包，如果直接加maven引用会导致jar冲突。</p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>javax.servlet<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>javax.servlet-api<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.0.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">scope</span>&gt;</span>provided<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>javax.servlet.jsp<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>jsp-api<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">scope</span>&gt;</span>provided<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="Maven-引用的jar包导致的冲突（dependencies工具）"><a href="#Maven-引用的jar包导致的冲突（dependencies工具）" class="headerlink" title="**Maven ** 引用的jar包导致的冲突（dependencies工具）"></a>**Maven ** 引用的jar包导致的冲突（dependencies工具）</h3><p>可以直接用exclusions排除，或者使用show dependencies查看冲突关系</p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.struts<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>struts-core<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.3.10<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">exclusions</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">exclusion</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>org.apache.commons<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>commons-lang3<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">exclusion</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">exclusions</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image016.jpg" alt="img"></p>
<p><img src="https://mixley.stdcdn.com/2021/07/maven/clip_image018.jpg" alt="img"></p>
<h2 id="补充"><a href="#补充" class="headerlink" title="补充"></a>补充</h2><h3 id="maven指令"><a href="#maven指令" class="headerlink" title="maven指令"></a>maven指令</h3><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">打包指定项目，并同时打包项目相关依赖</span></span><br><span class="line">mvn package -pl xxx -am</span><br></pre></td></tr></table></figure>

<h3 id="ant插件执行打包单个项目的配置"><a href="#ant插件执行打包单个项目的配置" class="headerlink" title="ant插件执行打包单个项目的配置"></a>ant插件执行打包单个项目的配置</h3><figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 父组件里面使用这个--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-antrun-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">tasks</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">condition</span> <span class="attr">property</span>=<span class="string">&quot;osFamily&quot;</span> <span class="attr">value</span>=<span class="string">&quot;windows&quot;</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">os</span> <span class="attr">family</span>=<span class="string">&quot;windows&quot;</span> /&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">condition</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">condition</span> <span class="attr">property</span>=<span class="string">&quot;osFamily&quot;</span> <span class="attr">value</span>=<span class="string">&quot;unix&quot;</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">os</span> <span class="attr">family</span>=<span class="string">&quot;unix&quot;</span> /&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">condition</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">exec</span> <span class="attr">dir</span>=<span class="string">&quot;../&quot;</span> <span class="attr">executable</span>=<span class="string">&quot;C:\\Windows\\System32\\cmd.exe&quot;</span> <span class="attr">osfamily</span>=<span class="string">&quot;windows&quot;</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">arg</span> <span class="attr">line</span>=<span class="string">&quot;/c &quot;</span>/&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">arg</span> <span class="attr">line</span>=<span class="string">&quot;echo &#x27;chcp 65001 <span class="symbol">&amp;amp;</span> mvn package -pl $&#123;artifactId&#125; -am -Dfile.encoding=UTF-8&#x27; <span class="symbol">&amp;amp;</span>&quot;</span>/&gt;</span></span><br><span class="line">                <span class="comment">&lt;!-- 这里防止输出乱码的 --&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">arg</span> <span class="attr">line</span>=<span class="string">&quot;set MAVEN_OPTS=-Dfile.encoding=UTF-8 <span class="symbol">&amp;amp;</span>&quot;</span>/&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">arg</span> <span class="attr">line</span>=<span class="string">&quot;chcp 65001 <span class="symbol">&amp;amp;</span> mvn package -pl $&#123;artifactId&#125; -am -Dfile.encoding=UTF-8&quot;</span>/&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">exec</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">exec</span> <span class="attr">dir</span>=<span class="string">&quot;../&quot;</span> <span class="attr">executable</span>=<span class="string">&quot;/bin/bash&quot;</span> <span class="attr">osfamily</span>=<span class="string">&quot;unix&quot;</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">arg</span> <span class="attr">line</span>=<span class="string">&quot;-c mvn package -pl $&#123;artifactId&#125; -am -Dfile.encoding=UTF-8&quot;</span>/&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">exec</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">tasks</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>


      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/22ZWC5R.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/22ZWC5R.html" class="post-title-link" itemprop="url">配置优先级</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-11-03 22:12:01" itemprop="dateModified" datetime="2021-11-03T22:12:01+08:00">2021-11-03</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/22ZWC5R.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/22ZWC5R.html" class="cy_cmt_count" data-xid="2022/22ZWC5R.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>前言<br>本文介绍SpringBoot常用外部化配置方法，其中优先级数值越高，优先级越大，会覆盖优先级底的配置</p>
<p>配置文件方式（优先级3）<br>boostrap.yml内指定spring.cloud.nacos.config.server-addr参数参考如下：</p>
<p>spring:<br>  application:<br>    name: service-a<br>  cloud:<br>    nacos:<br>      config:<br>        server-addr: 127.0.0.1:8848<br>        file-extension: yml<br>      discovery:<br>        server-addr: 127.0.0.1:8848<br>项目打包</p>
<p>target/service-a-0.0.1-SNAPSHOT.jar</p>
<p>Java系统属性方式（优先级6）<br>java -jar target/service-a-0.0.1-SNAPSHOT.jar -Dspring.cloud.nacos.config.server-addr=127.0.0.2:8848<br>命令行参数方式（优先级11）<br>java -jar target/service-a-0.0.1-SNAPSHOT.jar –spring.cloud.nacos.config.server-addr=127.0.0.3:8848<br>系统环境变量参数方式（优先级5）<br>export SPRING_CLOUD_NACOS_CONFIG_SERVERADDR=127.0.0.4:8848<br>java -jar target/service-a-0.0.1-SNAPSHOT.jar<br>注意：环境变量同意采用大写字母，不允许使用.-符号，采用下划线“_”取代点“.”  减号“-”直接删除。</p>
<p>说明：系统环境变量方式自由度高，可配合k8s部署脚本，动态切换到各运行环境</p>
<p>参考如下：</p>
<p>kind: Deployment<br>apiVersion: apps/v1<br>metadata:<br>  name: service-a<br>spec:<br>  template:<br>    spec:<br>      containers:<br>        - name: service-a<br>          env:<br>            - name: SPRING_PROFILES_ACTIVE<br>              value: prod<br>            - name: JAVA_OPTIONS<br>              value: ‘-XX:MaxRAMFraction=2’<br>            - name: SPRING_CLOUD_NACOS_CONFIG_SERVERADDR<br>              value: ‘10.0.0.2:8848’<br>            - name: SPRING_CLOUD_NACOS_DISCOVERY_SERVERADDR<br>              value: ‘10.0.0.2:8848’</p>
<p>加载顺序、优先级参考<br>Spring Boot uses a very particular PropertySource order that is designed to allow sensible<br>overriding of values. Properties are considered in the following order (with values from lower<br>items overriding earlier ones):</p>
<ol>
<li>Default properties (specified by setting SpringApplication.setDefaultProperties).</li>
<li>@PropertySource annotations on your @Configuration classes. Please note that such property<br>sources are not added to the Environment until the application context is being refreshed. This is<br>too late to configure certain properties such as logging.* and spring.main.* which are read<br>before refresh begins.</li>
<li>Config data (such as application.properties files)</li>
<li>A RandomValuePropertySource that has properties only in random.*.</li>
<li>OS environment variables.</li>
<li>Java System properties (System.getProperties()).</li>
<li>JNDI attributes from java:comp/env.</li>
<li>ServletContext init parameters.</li>
<li>ServletConfig init parameters.</li>
<li>Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or<br>system property).</li>
<li>Command line arguments.</li>
<li>properties attribute on your tests. Available on @SpringBootTest and the test annotations for<br>54testing a particular slice of your application.</li>
<li>@TestPropertySource annotations on your tests.</li>
<li>Devtools global settings properties in the $HOME/.config/spring-boot directory when devtools is<br>active.</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://mixley.github.io/2022/7PXA8K.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="mixley">
      <meta itemprop="description" content="全栈·架构设计·算法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="mixley">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/7PXA8K.html" class="post-title-link" itemprop="url">Spring Cloud注册中心</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-06-12 14:35:17" itemprop="dateCreated datePublished" datetime="2022-06-12T14:35:17+08:00">2022-06-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-11-03 22:01:45" itemprop="dateModified" datetime="2021-11-03T22:01:45+08:00">2021-11-03</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/" itemprop="url" rel="index"><span itemprop="name">学习</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/learn/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    
      <a title="changyan" href="/2022/7PXA8K.html#SOHUCS" itemprop="discussionUrl">
        <span id="url::https://mixley.github.io/2022/7PXA8K.html" class="cy_cmt_count" data-xid="2022/7PXA8K.html" itemprop="commentCount"></span>
      </a>
    
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/bc2587ec4e56">https://www.jianshu.com/p/bc2587ec4e56</a></p>
<h3 id="1、-什么是注册中心"><a href="#1、-什么是注册中心" class="headerlink" title="1、 什么是注册中心"></a>1、 什么是注册中心</h3><p>注册中心可以说是微服务架构中的”通讯录“，它记录了服务和服务地址的映射关系。在分布式架构中，服务会注册到这里，当服务需要调用其它服务时，就到这里找到服务的地址，进行调用。<br> 服务提供者provider: 启动的时候向注册中心上报自己的网络信息。<br> 服务消费者consumer: 启动的时候向注册中心上报自己的网络信息，拉取provider的相关网络信息。</p>
<h3 id="2-、为什么需要注册中心"><a href="#2-、为什么需要注册中心" class="headerlink" title="2 、为什么需要注册中心"></a>2 、为什么需要注册中心</h3><p>微服务应用和机器越来越多，调用方需要知道接口的网络地址，如果靠配置文件的方式去控制网络地址，对于动态新增机器，维护带来很大问题。</p>
<ul>
<li>主流的注册中心：zookeeper、Eureka、consul、etcd 等</li>
</ul>
<h3 id="3、分布式应用知识CAP定理"><a href="#3、分布式应用知识CAP定理" class="headerlink" title="3、分布式应用知识CAP定理"></a>3、分布式应用知识CAP定理</h3><p>CAP定理：指的是在一个分布式系统中，Consistency（一致性）、 Availability（可用性）、Partition tolerance（分区容错性）,三者不可同时获得。</p>
<ul>
<li>一致性（C）：在分布式系统中的所有数据备份，在同一时刻是否同样的值。（所有节点在同一时间的数据完全一致，越多节点，数据同步越耗时）。</li>
<li>可用性（A）：负载过大后，集群整体是否还能响应客户端的读写请求。（服务一直可用，而且是正常响应时间）。</li>
<li>分区容错性（P）：分区容忍性，就是高可用性，一个节点崩了，并不影响其它的节点（100个节点，挂了几个，不影响服务，越多机器越好）。</li>
</ul>
<h3 id="4、分布式系统CAP注册中心选择"><a href="#4、分布式系统CAP注册中心选择" class="headerlink" title="4、分布式系统CAP注册中心选择"></a>4、分布式系统CAP注册中心选择</h3><p>CAP三者不可同时获得的原因：</p>
<ol>
<li>C A 满足的情况下，P不能满足的原因：<br> 数据同步(C)需要时间，也要正常的时间内响应(A)，那么机器数量就要少，所以P就不满足。</li>
<li>CP 满足的情况下，A不能满足的原因：<br> 数据同步(C)需要时间, 机器数量也多(P)，但是同步数据需要时间，所以不能再正常时间内响应，所以A就不满足。</li>
<li>AP 满足的情况下，C不能满足的原因：<br> 机器数量也多(P)，正常的时间内响应(A)，那么数据就不能及时同步到其他节点，所以C不满足。</li>
</ol>
<h6 id="注册中心选择："><a href="#注册中心选择：" class="headerlink" title="注册中心选择："></a>注册中心选择：</h6><ul>
<li><p>Zookeeper：CP设计，保证了一致性，集群搭建的时候，某个节点失效，则会进行选举行的leader，或者半数以上节点不可用，则无法提供服务，因此可用性没法满足</p>
</li>
<li><p>Eureka：AP原则，无主从节点，一个节点挂了，自动切换其他节点可以使用，去中心化<br> 结论：没有最好的选择，最好是根据业务场景来进行架构设计</p>
<p>注册中心对比图：</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-6939c67bd9713238.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
<p>注册中心对比图</p>
</li>
</ul>
<h3 id="5、注册中心搭建-使用IDEA"><a href="#5、注册中心搭建-使用IDEA" class="headerlink" title="5、注册中心搭建(使用IDEA)"></a>5、注册中心搭建(使用IDEA)</h3><p>File –&gt; New –&gt;Project</p>
<ul>
<li><p>拉取项目</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-b170be204585485a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-3252793a85e5e2cc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-9d74d4f2f2e3e735.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
</li>
<li><p>打开项目在启动类添加注解@EnableEurekaServer</p>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@SpringBootApplication</span></span><br><span class="line"><span class="meta">@EnableEurekaServer</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">EurekaServerApplication</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        SpringApplication.run(EurekaServerApplication.class, args);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>增加配置application.yml<br> (配置文件默认是application.properties格式，如需修改为yml直接重命名即可)</li>
</ul>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">server:</span><br><span class="line">  port: 8761</span><br><span class="line"></span><br><span class="line">eureka:</span><br><span class="line">  instance:</span><br><span class="line">    hostname: localhost</span><br><span class="line">  client:</span><br><span class="line">  <span class="comment">#声明自己是个服务端</span></span><br><span class="line">    registerWithEureka: <span class="literal">false</span></span><br><span class="line">    fetchRegistry: <span class="literal">false</span></span><br><span class="line">    serviceUrl:</span><br><span class="line">      defaultZone: http://<span class="variable">$&#123;eureka.instance.hostname&#125;</span>:<span class="variable">$&#123;server.port&#125;</span>/eureka/</span><br></pre></td></tr></table></figure>

<ul>
<li>启动项目 访问注册中心页面<br> http:// localhost:8761</li>
</ul>
<h3 id="6、创建服务提供者向注册中心上报"><a href="#6、创建服务提供者向注册中心上报" class="headerlink" title="6、创建服务提供者向注册中心上报"></a>6、创建服务提供者向注册中心上报</h3><ul>
<li><p>如上所示创建注册中心一样创建项目，不同的是选择依赖如下:</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-7d25bbaf0be5406e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
</li>
<li><p>开发接口</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-e284a51d7b3ae84d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
</li>
<li><p>增加配置application.yml</p>
</li>
</ul>
<figure class="highlight csharp"><table><tr><td class="code"><pre><span class="line">server:</span><br><span class="line">  port: <span class="number">8771</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#服务的名称</span></span><br><span class="line">spring:</span><br><span class="line">  application:</span><br><span class="line">    name: product-service</span><br><span class="line"></span><br><span class="line"><span class="meta">#指定注册中心地址</span></span><br><span class="line">eureka:</span><br><span class="line">  client:</span><br><span class="line">    service-url:</span><br><span class="line">      defaultZone: http:<span class="comment">//localhost:8761/eureka/</span></span><br></pre></td></tr></table></figure>

<ul>
<li><p>启动服务</p>
<p>此时访问注册中心地址：http:// localhost:8761 就可以看到如下注册的服务了</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-ead6dfe3cad3ef26.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
</li>
</ul>
<h3 id="7、Eureka服务注册中心配置控制台问题"><a href="#7、Eureka服务注册中心配置控制台问题" class="headerlink" title="7、Eureka服务注册中心配置控制台问题"></a>7、Eureka服务注册中心配置控制台问题</h3><ol>
<li><p>eureka管理后台出现一串红色字体：是警告，说明有服务上线率低                 </p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-2947d933608a24ef.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
<p>由于自我保护模式默认是开启状态<br> 关闭检查方法：eureka服务端配置文件加入</p>
</li>
</ol>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">server:</span><br><span class="line">  enable-self-preservation: <span class="literal">false</span></span><br></pre></td></tr></table></figure>

<p>注意:不建议关闭，因为关闭会导致如若因为网络问题没上报至注册中心的服务也会被认为挂掉而清除掉了此服务。</p>
<ol>
<li><p>为什么只加一个注册中心地址，就可以注册，而且很多资料显示启动类加注解@EnableEurekaClient</p>
<p>查阅官网，给出解释如下：</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16750801-ce9478fd6ad5ab9e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1200/format/webp" alt="img"></p>
<p>官方文档：</p>
<p><a target="_blank" rel="noopener" href="http://cloud.spring.io/spring-cloud-netflix/single/spring-cloud-netflix.html#spring-cloud-eureka-server">http://cloud.spring.io/spring-cloud-netflix/single/spring-cloud-netflix.html#spring-cloud-eureka-server</a></p>
</li>
</ol>
<p>作者：二圈儿<br>链接：<a target="_blank" rel="noopener" href="https://www.jianshu.com/p/bc2587ec4e56">https://www.jianshu.com/p/bc2587ec4e56</a><br>来源：简书<br>著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><span class="space">&hellip;</span><a class="page-number" href="/page/5/">5</a><a class="extend next" rel="next" href="/page/3/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">mixley</p>
  <div class="site-description" itemprop="description">全栈·架构设计·算法</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">43</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">10</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">mixley</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

  <script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=cyvxnSprz"></script>


</body>
</html>
